#ifndef QSCALEWIDGET_H
#define QSCALEWIDGET_H

#include "qabstractgraphics.h"

#include <QWidget>

enum enScaleType
{
    ST_Horizontal,
    ST_Vertical
};

enum enTextPosition
{
    TP_POSITION_1,
    TP_POSITION_2
};

class QScaleWidget : public QAbstractGraphicsWidget
{
    Q_OBJECT
    Q_PROPERTY(int type READ type WRITE setType)
    Q_PROPERTY(int main_count READ mainCount WRITE setMainCount)
    Q_PROPERTY(int subsidiary_count READ subsidiaryCount WRITE setSubsidiaryCount)
    Q_PROPERTY(QString format READ format WRITE setFormat)
    Q_PROPERTY(double maxValue READ maxValue WRITE setMaxValue)
    Q_PROPERTY(double minValue READ minValue WRITE setMinValue)
    Q_PROPERTY(bool invertedAppearance READ invertedAppearance WRITE setInvertedAppearance)
    Q_PROPERTY(int textPosition READ textPosition WRITE setTextPosition)
    Q_PROPERTY(bool textVisible READ textVisible WRITE setTextVisible)
public:
    explicit QScaleWidget(QWidget *parent = 0);

    void paintEvent(QPaintEvent *);

    int     type();
    void    setType(int type);

    int     mainCount();
    void    setMainCount(int count);

    int     subsidiaryCount();
    void    setSubsidiaryCount(int count);

    QString format();
    void    setFormat(const QString &str);

    double  maxValue();
    void    setMaxValue(double value);

    double  minValue();
    void    setMinValue(double value);

    void    setInvertedAppearance(bool invertedAppearance);
    bool    invertedAppearance();

    void    setTextPosition(int textPosition);
    int     textPosition();

    bool    textVisible();
    void    setTextVisible(bool textVisible);
protected:
    void    draw_horizontal(QPainter *p);
    void    draw_vertical(QPainter* p);

    void    update_text();
signals:

public slots:
protected:
    int     m_type;
    int     m_main_count;
    int     m_subsidiary_count;
    double  m_min;
    double  m_max;
    QStringList m_texts;
    QString m_format;
    bool    m_invertedAppearance;
    int     m_text_position;
    QBrush  m_text_brush;
    bool    m_textVisible;
};



class QScaleWidgetHost : public QAbstractGraphicsHost
{
    Q_OBJECT
public:
    Q_INVOKABLE QScaleWidgetHost(QAbstractHost *parent = 0);

    static QString get_show_name();
    static QString get_show_icon();
    static QString get_show_group();
public slots:

    int     type();
    void    setType(int type);

    double  max_value();
    void    set_max_value(double value);

    double  min_value();
    void    set_min_value(double value);

    bool    text_visible();
    void    set_text_visible(bool visible);
protected:
    void init_property();
protected:
    void    create_object();
};

#endif // QSCALEWIDGET_H
